package com.woniuxy.intellihome.mapper;

import com.woniuxy.intellihome.entity.Address;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2021-08-11
 */
public interface AddressMapper extends BaseMapper<Address> {
    @Select("select * from m_address where user_id=#{user_id}")
    List<Address> getByUserId(int user_id);

    @Select("select * from m_address where isdefault=#{isdefault} and user_id=#{user_id}")
    Address getDefault(@Param("user_id") int user_id, @Param("isdefault") String isdefault);

    @Select("select count(*) from m_address where user_id=#{user_id}")
    int getAddressNumsByUser_id(int user_id);

}
